home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / src / stubc / sc3d.c next >
Encoding:
C/C++ Source or Header  |  1994-03-23  |  2.4 KB  |  101 lines

  1. /* $Id: sc3d.c,v 1.7 1994/03/23 08:37:18 mjl Exp $
  2.  * $Log: sc3d.c,v $
  3.  * Revision 1.7  1994/03/23  08:37:18  mjl
  4.  * Some cruft elimination.
  5.  * All external API source files: replaced call to plexit() on simple
  6.  * (recoverable) errors with simply printing the error message (via
  7.  * plabort()) and returning.  Should help avoid loss of computer time in some
  8.  * critical circumstances (during a long batch run, for example).
  9.  *
  10. */
  11.  
  12. /*    sc3d.c
  13.  
  14.     Stub routines for 3d plots.
  15. */
  16.  
  17. #include "plstubs.h"
  18.  
  19. void
  20. PLMESH(PLFLT *x, PLFLT *y, PLFLT *z,
  21.        PLINT *nx, PLINT *ny, PLINT *opt, PLINT *lx)
  22. {
  23.     int i, j;
  24.     PLFLT **temp;
  25.  
  26.     /* Create the vectored C matrix from the Fortran matrix */
  27.     /* To make things easy we save a temporary copy of the transpose of the
  28.        Fortran matrix, so that the first dimension of z corresponds to the x
  29.        direction. */
  30.  
  31.     if ( ! (temp = (PLFLT **) malloc((size_t) * nx * sizeof(PLFLT *)))) {
  32.     plabort("PLMESH: Out of memory");
  33.     return;
  34.     }
  35.  
  36.     for (i = 0; i < *nx; i++) {
  37.     if ( ! (temp[i] = (PLFLT *) malloc((size_t) * ny * sizeof(PLFLT)))) {
  38.         int ii;
  39.  
  40.         for (ii = 0; ii < i-1; ii++)
  41.         free((void *) temp[i]);
  42.         free((void *) temp);
  43.         plabort("PLMESH: Out of memory");
  44.         return;
  45.     }
  46.     }
  47.  
  48.     for (i = 0; i < *nx; i++)
  49.     for (j = 0; j < *ny; j++)
  50.         temp[i][j] = *(z + j * *lx + i);
  51.  
  52.     c_plmesh(x, y, temp, *nx, *ny, *opt);
  53.  
  54.     for (i = 0; i < *nx; i++)
  55.     free((void *) temp[i]);
  56.  
  57.     free((void *) temp);
  58. }
  59.  
  60.  
  61. void
  62. PLOT3D(PLFLT *x, PLFLT *y, PLFLT *z,
  63.        PLINT *nx, PLINT *ny, PLINT *opt, PLINT *side, PLINT *lx)
  64. {
  65.     int i, j;
  66.     PLFLT **temp;
  67.  
  68.     /* Create the vectored C matrix from the Fortran matrix */
  69.     /* To make things easy we save a temporary copy of the transpose of the
  70.        Fortran matrix, so that the first dimension of z corresponds to the x
  71.        direction. */
  72.  
  73.     if ( ! (temp = (PLFLT **) malloc((size_t) * nx * sizeof(PLFLT *)))) {
  74.     plabort("PLOT3D: Out of memory");
  75.     return;
  76.     }
  77.  
  78.     for (i = 0; i < *nx; i++) {
  79.     if ( ! (temp[i] = (PLFLT *) malloc((size_t) * ny * sizeof(PLFLT)))) {
  80.         int ii;
  81.  
  82.         for (ii = 0; ii < i-1; ii++)
  83.         free((void *) temp[i]);
  84.         free((void *) temp);
  85.         plabort("PLOT3D: Out of memory");
  86.         return;
  87.     }
  88.     }
  89.  
  90.     for (i = 0; i < *nx; i++)
  91.     for (j = 0; j < *ny; j++)
  92.         temp[i][j] = *(z + j * *lx + i);
  93.  
  94.     c_plot3d(x, y, temp, *nx, *ny, *opt, *side);
  95.  
  96.     for (i = 0; i < *nx; i++)
  97.     free((void *) temp[i]);
  98.  
  99.     free((void *) temp);
  100. }
  101.